#!/bin/env python
import sys

def gen_update_pyquda_singularity_define_files(old_version="v0.10.2",
                                        new_version="v0.10.8",
                                        sm="sm_35"):
    pyquda_imag="pyquda_" + old_version + "_quda_" + sm + "_cupy13.2_cuda11.8_ubuntu22.04"
    pyquda_update_def_file="pyquda_" + new_version + "_from_" + old_version + "_" + sm  
    pyquda_update_def=f"""Bootstrap:localimage
From: {pyquda_imag}.sif
%setup
%files
%post
    pip3 install gmpy2
    pip3 install -U setuptools
    pip3 install -U pip
    pip3 install -U pyquda pyquda-utils
%environment
%runscript
    """
    with open(pyquda_update_def_file + ".def","w") as f:
        f.writelines(pyquda_update_def)


for i in ["sm_35","sm_60","sm_70","sm_80"]:
    gen_update_pyquda_singularity_define_files(old_version="v0.10.2",new_version="v0.10.8",sm=i)
